<template>
  <div>
    <nav-bar>
      <div slot="left" class="left" @click="goback">
        <img src="~assets/img/common/back.svg" alt="" />
      </div>
      <div slot="center" class="center">
        <div
          v-for="(item, index) in navbarlist"
          :key="index"
          :class="{ active: currentindex === index }"
          @click="detailclick(index)"
        >
          {{ item }}
        </div>
      </div>
    </nav-bar>
  </div>
</template>
<script>
import NavBar from "components/common/navbar/NavBar";
export default {
  name: "DetailNavBar",
  data() {
    return {
      navbarlist: ["商品", "参数", "评论", "推荐"],
      currentindex: 0
    };
  },
  components: {
    NavBar
  },
  methods: {
    detailclick(index) {
      this.currentindex = index;
      this.$emit("goto", index);
    },
    goback() {
      this.$router.go(-1);
      // this.$router.back();
    }
  }
};
</script>
<style lang="css" scoped>
.left img {
  margin-top: 10px;
}
.center {
  display: flex;
  font-size: 14px;
}
.center div {
  flex: 1;
  text-align: center;
}
.active {
  color: #ff5777;
}
</style>
